package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOutticketLog;
import com.ktgj.flight.service.IFlightOutticketLogService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票订单出票日志Controller
 * 
 * @author ruoyi
 * @date 2022-02-15
 */
@RestController
@RequestMapping("/outticketLog")
public class FlightOutticketLogController extends BaseController
{
    @Autowired
    private IFlightOutticketLogService flightOutticketLogService;

    /**
     * 查询机票订单出票日志列表
     */
    @PreAuthorize(hasPermi = "flight:log:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOutticketLog flightOutticketLog)
    {
        startPage();
        List<FlightOutticketLog> list = flightOutticketLogService.selectFlightOutticketLogList(flightOutticketLog);
        return getDataTable(list);
    }

    /**
     * 导出机票订单出票日志列表
     */
    @PreAuthorize(hasPermi = "flight:log:export")
    @Log(title = "机票订单出票日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOutticketLog flightOutticketLog) throws IOException
    {
        List<FlightOutticketLog> list = flightOutticketLogService.selectFlightOutticketLogList(flightOutticketLog);
        ExcelUtil<FlightOutticketLog> util = new ExcelUtil<FlightOutticketLog>(FlightOutticketLog.class);
        util.exportExcel(response, list, "机票订单出票日志数据");
    }

    /**
     * 获取机票订单出票日志详细信息
     */
    @PreAuthorize(hasPermi = "flight:log:query")
    @GetMapping(value = "/{logid}")
    public AjaxResult getInfo(@PathVariable("logid") Long logid)
    {
        return AjaxResult.success(flightOutticketLogService.selectFlightOutticketLogById(logid));
    }

    /**
     * 新增机票订单出票日志
     */
    @PreAuthorize(hasPermi = "flight:log:add")
    @Log(title = "机票订单出票日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOutticketLog flightOutticketLog)
    {
        return toAjax(flightOutticketLogService.insertFlightOutticketLog(flightOutticketLog));
    }

    /**
     * 修改机票订单出票日志
     */
    @PreAuthorize(hasPermi = "flight:log:edit")
    @Log(title = "机票订单出票日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOutticketLog flightOutticketLog)
    {
        return toAjax(flightOutticketLogService.updateFlightOutticketLog(flightOutticketLog));
    }

    /**
     * 删除机票订单出票日志
     */
    @PreAuthorize(hasPermi = "flight:log:remove")
    @Log(title = "机票订单出票日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logids}")
    public AjaxResult remove(@PathVariable Long[] logids)
    {
        return toAjax(flightOutticketLogService.deleteFlightOutticketLogByIds(logids));
    }
}
